#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

void solve()
{
	string s;
	cin>>s;
	int n=s.size();
	bool ok=true;
	for(int i=0,j=0;i<n;)
	{
		char t=s[i];

		int sz=0;
		while(j<n&&s[j]==t)
		{
			j++;sz++;
		}
		string s2=s.substr(i,sz);
		if(s2.size()==1)
		{
			ok=false;
			break;
		}
		i=j;

	}

	if(ok) cout<<"YES"<<'\n';
	else cout<<"NO"<<'\n';
	
}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}
//aa aaa bb bbb